package ua.kharkov.knure.pereverziev.diploma.web.command;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

public class GoBack implements Command {
	private static final Logger log = Logger.getLogger(GotoCommand.class);

	@Override
	public String execute(HttpServletRequest request,
			HttpServletResponse response) throws IOException, ServletException {

		log.debug("Back command starts");
		String forward = (String) request.getSession().getAttribute("lastPage");
		if (forward == null)
			forward = "controller?command=logout";
		log.debug("Back command finished");
		return forward;
	}

}
